From 255d521f0a26360d27f381cc8184c0152bc9fa31 Mon Sep 17 00:00:00 2001 From: oliskoli Date: Sat, 14 Apr 2007 15:25:20 +0000 Subject: [PATCH] Use global defined index of datum WGS84 and OSGB36. --- compegps.c | 9 ++------- defs.h | 2 ++ dmtlog.c | 13 +++++-------- garmin_txt.c | 2 +- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/compegps.c b/compegps.c index 3156c55bd..b65b6912b 100644 --- a/compegps.c +++ b/compegps.c @@ -106,16 +106,11 @@ static void fix_datum(double *lat, double *lon) { double amt; - static int wgs84; - - if (wgs84 == 0) { - wgs84 = GPS_Lookup_Datum_Index("WGS 84"); - } /* * Avoid FP jitter in the common case. */ - if (input_datum != wgs84) { + if (input_datum != DATUM_WGS84) { GPS_Math_Known_Datum_To_WGS84_M(*lat, *lon, 0.0, lat, lon, &amt, input_datum); } @@ -341,7 +336,7 @@ static void compegps_rd_init(const char *fname) { fin = gbfopen(fname, "rb", MYNAME); - input_datum = GPS_Lookup_Datum_Index("WGS 84"); + input_datum = DATUM_WGS84; } static void diff --git a/defs.h b/defs.h index 43d30bd95..c0c68e56d 100644 --- a/defs.h +++ b/defs.h @@ -861,6 +861,8 @@ typedef enum { #define GRID_INDEX_MIN grid_lat_lon_ddd #define GRID_INDEX_MAX grid_utm + +#define DATUM_OSGB36 86 #define DATUM_WGS84 118 int parse_coordinates(const char *str, int datum, const grid_type grid, diff --git a/dmtlog.c b/dmtlog.c index 785ab0050..9a88c50aa 100644 --- a/dmtlog.c +++ b/dmtlog.c @@ -38,7 +38,7 @@ static char *xmlbin; static waypoint *xmlwpt; static route_head *xmltrk; static char *xmlgrid; -static int xmldatum, datum_WGS84, datum_OSGB36; +static int xmldatum; static double xmlEasting, xmlNorthing; static double xmlLatitude, xmlLongitude; static double xmlAltitude; @@ -105,7 +105,7 @@ static xg_tag_mapping tlog3b_xgcb_map[] = { static void convert_datum(waypoint *wpt, int datum) { - if (datum != datum_WGS84) { + if (datum != DATUM_WGS84) { double lat = wpt->latitude; double lon = wpt->longitude; double alt = wpt->altitude; @@ -122,7 +122,7 @@ finalize_pt(waypoint *wpt) if (strcmp(xmlgrid, "BNG") == 0) { GPS_Math_NGENToAiry1830LatLon(xmlEasting, xmlNorthing, &wpt->latitude, &wpt->longitude); - xmldatum = datum_OSGB36; + xmldatum = DATUM_OSGB36; } else { wpt->latitude = xmlLatitude; @@ -219,7 +219,7 @@ static void tlog3b_xgcb_wptst(const char *args, const char **unused) { xmlwpt = waypt_new(); - xmldatum = datum_WGS84; + xmldatum = DATUM_WGS84; } @@ -227,7 +227,7 @@ static void tlog3b_xgcb_tptst(const char *args, const char **unused) { xmlwpt = waypt_new(); - xmldatum = datum_WGS84; + xmldatum = DATUM_WGS84; } @@ -551,9 +551,6 @@ dmtlog_rd_init(const char *fname) { fin = gbfopen_le(fname, "rb", MYNAME); - datum_OSGB36 = GPS_Lookup_Datum_Index("OSGB36"); - datum_WGS84 = GPS_Lookup_Datum_Index("WGS84"); - xmlbin = NULL; xmltrk = NULL; xmlwpt = NULL; diff --git a/garmin_txt.c b/garmin_txt.c index bb8444f02..3638510d3 100644 --- a/garmin_txt.c +++ b/garmin_txt.c @@ -765,7 +765,7 @@ garmin_txt_wr_init(const char *fname) switch(grid_index) { case grid_bng: /* force datum to "Ord Srvy Grt Britn" */ - datum_index = gt_lookup_datum_index("OSGB36", MYNAME); + datum_index = DATUM_OSGB36; break; default: datum_index = gt_lookup_datum_index(datum_str, MYNAME); -- 2.30.2